package com.example.exam.utils;

import lombok.Data;

@Data
public class ResponsePojo<T> {
    private T data;
    private String message;
    private int code;

    private ResponsePojo(T data) {
        this.data = data;
        this.message = "";
        this.code = 1;
    }

    private ResponsePojo(T data, String message, int code) {
        this.data = data;
        this.message = message;
        this.code = code;
    }

    public static <T> ResponsePojo<T> success(T data) {
        return new ResponsePojo<>(data);
    }

    public static <T> ResponsePojo<T> fail(T data, String message) {
        return new ResponsePojo<>(data, message, 1);
    }
}
